<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //setInterval(函数，间隔时间)  间隔时间调用函数，所以函数不用加小括号
        let n = setInterval(function () { console.log('hahah'); }, 1000)//时间单位ms  1000ms=1s
        console.log(n);//打印出的n代表第几个闹钟

        clearInterval(n)//关闭计时器

    </script>
</body>

</html>